﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H


#include "xsane.h"
#include "externaltools.h"
#include "config.h"
#include "scene.h"
#include "helpinfodalog.h"
#include "anim.h"
#include "sessionmanager.h"
#include "scanner.h"
#include "pdffile.h"
#include "extractdialog.h"
#include "document.h"
#include "preferences.h"

#include <QMainWindow>



namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

private:
    Ui::MainWindow *ui;
    Config* m_config;
    SessionManager* m_sessionManager;
    QGraphicsView* m_gv1;
    QGraphicsView* m_gv2;
    Scene* m_scene1;
    BasicScene* m_scene2;
    QGraphicsPixmapItem* m_pixmapItem2;
    Document* m_document;
    QFileDialog* m_fileDialog;
    HelpInfoDialog* m_helpInfoDialog;
    Preferences* m_preferences;

    void fillOpenMenu ();
    void updateSession ();
    void readGlobalOptions ();
    void clear ();
    void initMenuScan();
    void open (const QString& documentPath);

    void initConnect();
public:
    explicit MainWindow (const QString& documentPath = QString (), CenteredWidget *parent = 0);
    ~MainWindow();
    void closeEvent (QCloseEvent *event);
    void dragEnterEvent (QDragEnterEvent *event);
    void dropEvent (QDropEvent *event);

private slots:
    void on_options_clicked();
    void openRecentFile ();
    void removeTemp ();
    void onActionOpen ();
    void on_help_clicked();
    void on_exit_clicked();
    void on_editUndo_clicked();
    void on_editRedo_clicked();
    void on_acquireFromScanner_clicked();
    void onDocumentIsEmpty (const bool b);
    void onPathChanged (const QString& documentPath);
    void onOriginalPixmapAvailable (const QPixmap& original);
    void onPreviewPixmapAvailable (const QPixmap& preview);
    void onRotationChanged (const int rotation);
    void onScaleChanged (const double scale);
    void onContrastChanged (const int contrast);
    void onOptionCleanImageChanged (const bool clean);
    void onTypePdfChanged (const bool b);
    void onPageRangeChanged (const int first, const int last);
    void onCurrentPageChanged (const int currentPg);
    void on_runOCR_clicked();
    void on_extractFromPDF_clicked();
    void onAskExtractionFrom (const QRectF& rectF);
    void onAskOCRFrom (ImagePart *part);
    void on_zoomOriginal1_clicked();
    void on_zoomBestFit1_clicked();
    void on_zoomOriginal2_clicked();
    void on_zoomBestFit2_clicked();

signals:
    void newTextForSpelling (const QString& text);
};

#endif // MAINWINDOW_H
